<script setup>

import {useScoreStore, useUserStore} from "../store/userStore.js";
import {updateScore} from "@/hook/scoreHook.js";
import router from "@/router/index.js";
let update = (async () => {
  await updateScore(useScoreStore().currentScore)
  window.location.hash = '#';
  await useScoreStore().updateScores(1,7)
})
</script>

<template>
  <form @submit.prevent="update">
  <!-- Put this part before </body> tag -->
  <div class="modal text-base-content" role="dialog" id="my_modal_9">
    <div class="modal-box">
      <h3 class="text-lg font-bold">编辑</h3>
      <fieldset class="fieldset">
      <legend class="fieldset-legend">成绩</legend>
      <input class="input join-item validator" placeholder="成绩" required
             maxlength="5" type="text"
             v-model="useScoreStore().currentScore.score"
             pattern="^(?:100(?:\.0{0,2})?|(?!100$)[1-9]?\d(?:\.\d{0,2})?|0(?:\.\d{1,2})?)$"/>
      <p class="validator-hint">
        成绩不合法
        <br/>请输入0~100的数字，可以有两位小数
      </p>
      </fieldset>
      <br>
      <div class="modal-action">
        <button type="submit" class="btn btn-ghost" >完成</button>
        <a href="#" class="btn btn-ghost">取消</a>
      </div>
    </div>
  </div>
  </form>
</template>

<style scoped>

</style>